home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
doorskl3.arc
/
XBBSMSG.ARC
/
MISCMSG.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-01-15
|
2KB
|
59 lines
/* Misc. XBBS message base functions */
#ifndef __TURBOC__
#define INCL_DOS
#include <os2.h> /* for DosSleep() */
#include <sys/locking.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <fcntl.h>
#include <share.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "xmsg.h"
#ifdef __TURBOC__
#define LK_LOCK 1
#define LK_UNLCK 2
#define DosSleep(x) sleep(1)
/* replacement for MSC's locking() in this module */
int pascal locking (int handle,int type,long length);
#define _fastcall pascal
#endif
/* external variables referenced */
extern char *msgpath;
unsigned int _fastcall how_many_msgs (unsigned int areano) {
/* returns number of messages in an area */
unsigned int tempsize;
struct stat st;
char filename[257];
sprintf(filename,"%sXDATA.%03x",msgpath,areano);
if(stat(filename,&st)) tempsize = 0;
else tempsize = (unsigned int)(st.st_size / (long)sizeof(XMSG));
if(tempsize) {
sprintf(filename,"%sXTEXT.%03x",msgpath,areano);
if(stat(filename,&st)) {
tempsize = 0;
sprintf(filename,"%sXDATA.%03x",msgpath,areano);
unlink(filename); /* eliminate orphaned header file */
/* note you may want to check for and */
/* try to restore an XTBAK.### file first */
}
return tempsize;
}